<?php
/**
 * 添加会员模板
 * User: crstu
 * Date: 2016/5/31
 * Time: 22:18
 */


use yii\helpers\Html;
use common\widgets\ActiveForm;
use common\widgets\FormTable;
use common\widgets\UploadImage;

$form = ActiveForm::begin([
    'options' => ['class' => 'form_box']
]);

?>

<div class="col-md-4">

<?php
echo FormTable::widget([
    'model' => $model,
    'form' => $form,
    'labelWidth' => 4,
    'rows' => [
        'realName' => [
            'type' => FormTable::INPUT_TEXT,
            'width' => 6,
        ],
        'phone' => [
            'type' => FormTable::INPUT_TEXT,
            'width' => 6,
        ],
        'paterTradeID' => [
            'type' => FormTable::INPUT_TEXT,
            'width' => 6,
            'options' => ['id' => 'paterID']
        ],
        'paterRealName' => [
            'type' => FormTable::INPUT_TEXT,
            'width' => 6,
            'options' => ['id' => 'paterRealName', 'disabled' => 'disabled']
        ],
    ]
]);
?>
</div>
<div class="col-md-8">
    <?php
    echo FormTable::widget([
        'model' => $model,
        'form' => $form,
        'rows' => [
            'identity' => [
                'type' => FormTable::INPUT_TEXT,
                'width' => 6,
            ],
        ]
    ]);
    ?>
    <div class="form-group">
        <label for="identityImage" class="col-sm-2 control-label">身份证照片：</label>
        <div class="col-sm-3 upload_img_box" data-tips="id_face">
            <?php
            echo UploadImage::widget(['model' => $model, 'attribute' => 'positiveCard']);
            ?>
        </div>
        <div class="col-sm-3 upload_img_box" data-tips="id_back">
            <?php
            echo UploadImage::widget(['model' => $model, 'attribute' => 'versoCard']);
            ?>
        </div>
    </div>
    <div class="form-group">
        <label for="bankCard" class="col-sm-2 control-label">银行卡号：</label>
        <div class="col-sm-4">
<!--            <input type="text" class="form-control" id="bankCardCode" placeholder="请输入会员银行卡号">-->
            <?php
            echo Html::activeTextInput($model, 'bankCardCode', ['class' => 'form-control']);
            ?>
        </div>
    </div>
    <div class="form-group">
        <label for="bankCardImage" class="col-sm-2 control-label">银行卡照片：</label>
        <div class="col-sm-4 upload_img_box" data-tips="bank_img">
            <?php
            echo UploadImage::widget(['model' => $model, 'attribute' => 'bankCard']);
            ?>
        </div>
    </div>
</div>
<?php
$form->end();

$this->beginBlock('footJs');
?>
<script type="text/javascript">
    $('#paterID').blur(function () {
        var id = $(this).val();
        if(id != ''){
            $.getJSON('/ajax/get-user-info.html', {tradeID:id}, function (response) {
                if(response.status){
                    var realName = response.data.realName;
                    if(realName != ''){
                        $('#paterRealName').val(realName);
                    }else{
                        $('#paterRealName').val('姓名为空');
                    }
                }else{
                    $('#paterRealName').val(response.message);
                }
            })
        }
    });
    $('#bankCard').blur(function () {
        
    });
</script>
<?php
$this->endBlock();